package me.zhengjie.utils;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.response.AlipayMerchantItemFileUploadResponse;
import com.alipay.api.request.AlipayMerchantItemFileUploadRequest;

import com.alipay.api.FileItem;
import java.util.Base64;
import java.util.ArrayList;
import java.util.List;





import com.alipay.api.domain.ItemOrderInfo;
import com.alipay.api.domain.OrderExtInfo;
import com.alipay.api.domain.OrderLogisticsInformationRequest;
import com.alipay.api.domain.AlipayMerchantOrderSyncModel;
import com.alipay.api.response.AlipayMerchantOrderSyncResponse;
import com.alipay.api.request.AlipayMerchantOrderSyncRequest;

import java.util.TimeZone;
import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * 支付宝上传图片
 */
public class AlipayMerchantItemFileUpload {

//    public static void main(String[] args) throws AlipayApiException {
//        // 初始化SDK
//        AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
//        //这是一个1x1像素的图片流
//        String imageBase64 = "iVBORw0KGgoAAAANSUhEUgAAAJAAAACQCAYAAADnRuK4AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f92UPVkLY8LGXbIEAIiOsCMgQWaIQkgBhhBASQMWFiApWFBURnEhVxILVCkidiOKgKLhnQYqIWotVXDjuH9yntX167+3t+9f7vOec5/zOec8PgBESJpHmomoAOVKFPDrYH49PSMTJvYACFUjgBCAQ5svCZwXFAADwA3l4fnSwP/wBr28AAgBw1S4kEsfh/4O6UCZXACCRAOAiEucLAZBSAMguVMgUAMgYALBTs2QKAJQAAGx5fEIiAKoNAOz0ST4FANipk9wXANiiHKkIAI0BAJkoRyQCQLsAYFWBUiwCwMIAoKxAIi4EwK4BgFm2MkcCgL0FAHaOWJAPQGAAgJlCLMwAIDgCAEMeE80DIEwDoDDSv+CpX3CFuEgBAMDLlc2XS9IzFLiV0Bp38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Nq5sxFccUHkpSngc8BD9l8d5aQ64+2sOCb71wimnwv7bu14sj8MK6LZxrwwC+IJrrX5rujUWNOp7dw4UkOQE34+6bNd38F/oGYx/AyDXrwF4HPoKLTo9p3u6EmMK6g+RZ4SUrGoWo03YL9ENFj0klvi/tGMg1shFeBM8U+r3ew6behoqU7tzBTQ5SvB34O7G/z/bXAp4E/JnEzmRQ0yHLpLXa8aD+x3wUbcrijyS7A94BbUQOiO9mQ5bNRIwBrkrqpTEoap4iqxfdjh+9PAO5AjekcsIMBZ6qA4k5xxafb/GYEOAk1YLotyZuLOh8orOyEilwvQhU1dyLh1wpHemEMA2ey8JwzsE74M+RtCX8MCK9MXNIGIEOmo4KLZ6KSoOzkZdTkxuXAn8YQcKYJcM7EvXzNMCoweE8jbzatADLkCNTA38k4VwV7TTjSjaj5TBubFDhHosYGT8G95lIZNZviGmwKPrUAZJV2AdDZuBf23CJc4FZURYlHgXdTDpqZ4jEtEO9qustv16MyPq+iznz1FoCcYx95cfvnYl3D3CzvAL8HbkLVcFyDqTh2A2UKqvrpYah5c/NRcS83eUHc9qupLXTaAlBAGY8aLOzBWkXdSTM9iQqu3Y9KMXk4wfvdB7XO2gfFNB1cR9MY8iRqlsl1OFQHawEonOyMKsVyKmpu90yPx70h2mgVqnjA86a/6wRw28T8GX+323iLxtYu2wTRLrMl1DBbtpnAHjZxGzvZhIqH/RQ1MPpq2olbMwPILHuIeTsRlbg/LeB5XhdwbZSXudG0vSnab4psk01bVsATZJ7dqGjEWwQ0DzQT8x8rADIT7jli2o4VYjohpW3/tHiNBdTqf681o+s41gBklomomSBzZfswKt1h9wbcywYxR48Kub9LTOZ6mlzGMoDs5GDRSgeg1vvYx7RNjOgaL4rXt0b+XyXAeSgNcZs4VP6OJE/IZsgk4UvTxDPaX/6fhBqDMjjOVNn3jmiTTSaOZPxfRlVsWytc6o0doUFDa6CW7NjyfwMAU41yHWIHb6IAAAAASUVORK5CYII=";
//        // 下列FileItem中也可用直接读取本地文件的方式来获取文件
//        // FileItem imageContent = new FileItem("本地文件的绝对路径");
//
//        // 构造请求参数以调用接口
//        AlipayMerchantItemFileUploadRequest request = new AlipayMerchantItemFileUploadRequest();
//
//        // 设置文件内容
//        FileItem fileContent = new FileItem("fileContent.jpg",Base64.getDecoder().decode(imageBase64));
//        request.setFileContent(fileContent);
//
//        // 设置业务场景描述
//        request.setScene("SYNC_ORDER");
//
//        AlipayMerchantItemFileUploadResponse response = alipayClient.execute(request);
//        System.out.println(response.getBody());
//
//        if (response.isSuccess()) {
//            System.out.println("调用成功");
//        } else {
//            System.out.println("调用失败");
//            // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
//            // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
//            // System.out.println(diagnosisUrl);
//        }
//    }


    public static void main(String[] args) throws AlipayApiException, ParseException {
        // 初始化SDK
        AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));

        // 构造请求参数以调用接口
        AlipayMerchantOrderSyncRequest request = new AlipayMerchantOrderSyncRequest();
        AlipayMerchantOrderSyncModel model = new AlipayMerchantOrderSyncModel();

        // 设置订单金额
        model.setAmount("12.34");

        // 设置订单创建时间
        model.setOrderCreateTime(sdf.parse("2020-01-01 08:00:00"));

        // 设置订单修改时间
        model.setOrderModifiedTime(sdf.parse("2020-01-01 08:00:01"));

        // 设置优惠金额
        model.setDiscountAmount("2.44");

        // 设置支付金额
        model.setPayAmount("9.9");

        // 设置商品信息列表
        List<ItemOrderInfo> itemOrderList = new ArrayList<ItemOrderInfo>();
        ItemOrderInfo itemOrderList0 = new ItemOrderInfo();
        itemOrderList0.setItemName("苹果");
        itemOrderList0.setQuantity(20L);
        itemOrderList0.setUnitPrice("13.18");
        List<OrderExtInfo> extInfodlcVW = new ArrayList<OrderExtInfo>();
        OrderExtInfo extInfodlcVW0 = new OrderExtInfo();
        extInfodlcVW0.setExtKey("image_material_id");
        extInfodlcVW0.setExtValue("2019082600502200000000000000");
        extInfodlcVW.add(extInfodlcVW0);
        OrderExtInfo extInfodlcVW1 = new OrderExtInfo();
        extInfodlcVW1.setExtKey("voucher_no");
        extInfodlcVW1.setExtValue("20221126999991Q7P");
        extInfodlcVW.add(extInfodlcVW1);
        OrderExtInfo extInfodlcVW2 = new OrderExtInfo();
        extInfodlcVW2.setExtKey("merchant_item_link_page");
        extInfodlcVW2.setExtValue("alipays://platformapi/startapp?appId=2014072300007148page=%2fpages%2forder-details%2forder-details%3fticketOrderId%3d20210000000");
        extInfodlcVW.add(extInfodlcVW2);
        OrderExtInfo extInfodlcVW3 = new OrderExtInfo();
        extInfodlcVW3.setExtKey("hdImageId");
        extInfodlcVW3.setExtValue("12345697");
        extInfodlcVW.add(extInfodlcVW3);
        OrderExtInfo extInfodlcVW4 = new OrderExtInfo();
        extInfodlcVW4.setExtKey("voucher_id");
        extInfodlcVW4.setExtValue("1234567");
        extInfodlcVW.add(extInfodlcVW4);
        itemOrderList0.setExtInfo(extInfodlcVW);
        itemOrderList.add(itemOrderList0);
        model.setItemOrderList(itemOrderList);

        // 设置订单物流信息请求
        List<OrderLogisticsInformationRequest> logisticsInfoList = new ArrayList<OrderLogisticsInformationRequest>();
        OrderLogisticsInformationRequest logisticsInfoList0 = new OrderLogisticsInformationRequest();
        logisticsInfoList0.setTrackingNo("P201802091000000002W");
        logisticsInfoList0.setLogisticsCode("STO");
        logisticsInfoList.add(logisticsInfoList0);
        model.setLogisticsInfoList(logisticsInfoList);

        // 设置外部订单号
        model.setOutBizNo("1234");

        // 设置支付宝交易号
        model.setTradeNo("2019052322001400191000023731");

        // 设置扩展信息
        List<OrderExtInfo> extInfoRPbkG = new ArrayList<OrderExtInfo>();
        OrderExtInfo extInfoRPbkG0 = new OrderExtInfo();
        extInfoRPbkG0.setExtKey("business_info");
        extInfoRPbkG0.setExtValue("{\"isv_id\":\"208888888888888\",\"come_again\":\"alipays://platformapi/startapp?appId=2014072300007148page=%2fpages%2forder-details%2forder-details%3fticketOrderId%3d20210000000\"}");
        extInfoRPbkG.add(extInfoRPbkG0);
        OrderExtInfo extInfoRPbkG1 = new OrderExtInfo();
        extInfoRPbkG1.setExtKey("merchant_biz_type");
        extInfoRPbkG1.setExtValue("KX_SHOPPING");
        extInfoRPbkG.add(extInfoRPbkG1);
        OrderExtInfo extInfoRPbkG2 = new OrderExtInfo();
        extInfoRPbkG2.setExtKey("merchant_order_status");
        extInfoRPbkG2.setExtValue("IN_DELIVERY");
        extInfoRPbkG.add(extInfoRPbkG2);
        OrderExtInfo extInfoRPbkG3 = new OrderExtInfo();
        extInfoRPbkG3.setExtKey("merchant_order_link_page");
        extInfoRPbkG3.setExtValue("/pages/order/orderDetail/orderDetail?orderId=2021083100000000");
        extInfoRPbkG.add(extInfoRPbkG3);
        OrderExtInfo extInfoRPbkG4 = new OrderExtInfo();
        extInfoRPbkG4.setExtKey("tiny_app_id");
        extInfoRPbkG4.setExtValue("2021004128699319");
        extInfoRPbkG.add(extInfoRPbkG4);
        model.setExtInfo(extInfoRPbkG);

        // uid参数未来计划废弃，存量商户可继续使用，新商户请使用openid。请根据应用-开发配置-openid配置选择支持的字段。
         model.setBuyerId("2088112162998728");

        // 设置支付宝openId
//        model.setBuyerOpenId("074a1CcTG1LelxKe4xQC0zgNdId0nxi95b5lsNpazWYoCo5");

        // 设置订单来源
        model.setSourceApp("Alipay");

        // 设置订单类型
        model.setOrderType("SERVICE_ORDER");

        request.setBizModel(model);
        // 第三方代调用模式下请设置app_auth_token
        // request.putOtherTextParam("app_auth_token", "<-- 请填写应用授权令牌 -->");

        AlipayMerchantOrderSyncResponse response = alipayClient.execute(request);
        System.out.println(response.getBody());

        if (response.isSuccess()) {
            System.out.println("调用成功");
        } else {
            System.out.println("调用失败");
            // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
            // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
            // System.out.println(diagnosisUrl);
        }
    }


    private static AlipayConfig getAlipayConfig() {
        String privateKey  = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCsZjaKJA5H9iBmfRze/bHWnj94PO0sKeIyZpWyjXsyxcsQCsp7c5/CW7ygoQrBsf8h4DQxFM/6CRndjMgIE9fUEUDKEp5hd2Xezi573Zcdi/ObYNHF9SOybdn8N//wggZLDQdSWVeXQaQjWE6/ehcA3wlKx9TqsAKtydzNc6fejtjtHm4abwsWikXooPIKqZdZEq5Cl8F+YBKrBAbfrs0HOzBqlomt65rjvHO+CZl/wIn4S5ZW0IRWRLZ3Bi21v1treP47atl/L3Uh3Kt01kynYr9dqXQoiceQZD2nWMD1Ky8zy/Ix0WnHhu2hhyXDw43RhCCZ0u2f/+XOqEkT7JRbAgMBAAECggEBAIoXaZJnZSURKkzN5KVdkui1Y2OdceDRP8VdVIVsPIWj147nBd+y8wIM11/W/zW9rP5mh4fVAu5mAdjr3oJR2qyckUgLd9/ccrXwc112VogtRRltiTpGrKxMv7H+7Typ+f591iKJO9cFlkNVheZsFib1gIzs2kiOaebo7buH66wha51QmTOLm848ygb5utQhl+JnqO5u+fpyFo2jbPufT0W/fsxbWuJhBBTV9oBpsk7MlpZ3G10arnqMBrYzgkJyigtX7FlK8+5HKim8pweUhAxsO8E372R4PjL/ZYdLfE7+zBjFha2h/m34jLDECfi12I16U9LOqirlPtlU28of0HECgYEA/Mst1lDNYlZGzCMtQrc0Gb6wIB6bAWpivAQulP2TB/423q7N1TrefUVM5G3CZLZBkFhnLuK3X1N/O/kCeXnYzeoa4SC3+l7ZPcC2dehwsASzyURJubx4WmZGj1u3FHVAW/Or4jsD4QKH5wRS/SFtA2FyvVO14kv7fVs8oW+r7YMCgYEArpX+UDUW6WlOF0JW3qKXInVZWLJlVUH9os6PIVXVvw0hB8UgfkVlf3l9cmcnUHHvqHePEr/20KEC8oysMLI5TqQVrqbhrndG/n+ok/MXfBqGnuq9cJ3rRKmoNZwHKzAdfQJKhqz8jf4aF8nCGFUrtnPviZbPWXlOlorM9olFnkkCgYEAl1vwLgpjbyXJbiEB0JhxEZkjS5gHp2lThM/cNEk/5+FGaT6w76M35DnCOGOfqT2XNB46adBFi0YrQHVwDdvu/BvXzEQS5E42NMtWdHKgRkQKgc/pdNRsG3RxexSnIhCyYFwd5m7/e5JQXPox1m5VH1kRolqk5MIp6nzeaKq8fpECgYEAiaHDf9Wqf029+0YYF6FTxh1+1xakHgdM/Zkbausw+1FNVcPIruLkdg7/nz3E131KsqO2TdC5sZUNLstJP4Zw+RcP5MS4q4JqnF1lN2VvgS2kLQnfWDWWcGXTLpgXaquew5sXx33+B65nQZOTiP0z3b0d/HjAc8fW9YTsufpTwMkCgYAV13PxXERCGuWAnH+q6sMFWTGh+5w/XjIjFd10eePvL6wYz1jSxXoQmThHY1+JzFZuH7O8S9W6R4QEg9ewjN8VS7w2go8AL623J4cL72nbCjkHyGa00vSB0fiWQ3u0IjoI1xvI8ZRTegw1Vqp2zH4WgOSqU7dnCjcuhIh53++6Bg==";
        String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsXkhdjkcQprB8Ghz4a9wwzIfIYheUfIVLeVKOHgA8oMDukncEbXFu1oVT2T3kqyeiEQCrCxfoOdkuFxLaLzl0zlJvOslVhB7lBhgxVi7agrTFBWlhEFPEbQR4GZpK4OvR+39UWln2ZWCt3wnNpTqjA97ujnZXIl2jLnNA7QoyePY3sGLi7+G7aRy68wLTHMlAyc5FdO+RtmSJ7ZGyaAwXteG44AIJY0Zgg5pQ+04jSOarxstyb4GmINp77sgTon+Gf7iQMFRgHP6KKxD//VDxOX8cPERm9u24YCI+dZkNWnmAXbPuB8KUoCanYgHp/EJSoH2jETZ4u7ADWv5wYtXJQIDAQAB";
        AlipayConfig alipayConfig = new AlipayConfig();
        alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
        alipayConfig.setAppId("2021004128699319");
        alipayConfig.setPrivateKey(privateKey);
        alipayConfig.setFormat("json");
        alipayConfig.setAlipayPublicKey(alipayPublicKey);
        alipayConfig.setCharset("UTF-8");
        alipayConfig.setSignType("RSA2");
        return alipayConfig;
    }
}
